Skip to content

Refactor namespaces with singleton keys#300

Merged
joaosreis merged 3 commits into
mainfrom
joaosreis/refactor-singleton-key-namespaces
May 14, 2026
Merged

Refactor namespaces with singleton keys#300
joaosreis merged 3 commits into
mainfrom
joaosreis/refactor-singleton-key-namespaces

Conversation

@joaosreis
Copy link
Copy Markdown
Member

Some namespaces should only have a single entry. For these namespaces, epochNo was being used, which doesn't make sense.
This PR refactor such namespaces to use a singleton value (1-byte) for the key.

@joaosreis joaosreis force-pushed the joaosreis/refactor-singleton-key-namespaces branch from 6760957 to b4ae492 Compare May 14, 2026 08:43
@joaosreis joaosreis marked this pull request as ready for review May 14, 2026 08:44
@joaosreis joaosreis requested review from Copilot and qnikst May 14, 2026 08:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors three namespaces (entities/committee/v0, gov/committee/v0, gov/constitution/v0) that semantically only ever have a single entry: their NamespaceKeySize is changed from 8 (previously an epochNo) to 1, reflecting a singleton 1-byte key.

Changes:

  • Set NamespaceKeySize "entities/committee/v0" = 1 (was 8).
  • Set NamespaceKeySize "gov/committee/v0" = 1 (was 8).
  • Set NamespaceKeySize "gov/constitution/v0" = 1 (was 8).
Comments suppressed due to low confidence (3)

scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs:122

  • The key size for gov/committee/v0 was reduced from 8 to 1 (singleton key), but the kaitai schema in the record_entry comment in Cardano/SCLS/Namespace/GovCommittee.hs (lines 30-35) still describes the key as epoch: u8 (8 bytes). That documentation is now inconsistent with the actual key size and should be updated to describe the new 1-byte singleton key.
type instance Spec.NamespaceKeySize "gov/committee/v0" = 1

scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs:123

  • The key size for gov/constitution/v0 was reduced from 8 to 1 (singleton key), but the kaitai schema in the record_entry comment in Cardano/SCLS/Namespace/GovConstitution.hs (lines 29-33) still describes the key as epoch: u8 (8 bytes). That documentation is now inconsistent with the actual key size and should be updated to describe the new 1-byte singleton key.
type instance Spec.NamespaceKeySize "gov/constitution/v0" = 1

scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs:123

  • For consistency with the other singleton entries in this file (e.g. nonces/v0 on line 114 and gov/proposals/roots/v0 on line 126), please add a trailing comment explaining what the single byte represents (e.g. -- Just zero / singleton key), to make the intent clear and match the established style for 1-byte singleton namespaces.
type instance Spec.NamespaceKeySize "entities/committee/v0" = 1
type instance Spec.NamespaceKeySize "entities/dreps/v0" = 29 -- 1 byte for tag, 28 bytes for hash
type instance Spec.NamespaceKeySize "entities/stake_pools/v0" = 28
type instance Spec.NamespaceKeySize "entities/stake_pools/vrf_key_hashes/v0" = 32
type instance Spec.NamespaceKeySize "gov/committee/v0" = 1
type instance Spec.NamespaceKeySize "gov/constitution/v0" = 1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs Outdated
@joaosreis joaosreis merged commit 30bb931 into main May 14, 2026
26 checks passed
@joaosreis joaosreis deleted the joaosreis/refactor-singleton-key-namespaces branch May 14, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants